<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\GoodsCategory;
use Dcat\Admin\Form;
use Dcat\Admin\Grid;
use Dcat\Admin\Show;
use Dcat\Admin\Http\Controllers\AdminController;

class GoodsCategoryController extends AdminController
{
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new GoodsCategory(), function (Grid $grid) {
            $grid->model()->where('country','=',config('app.goods_country'));
            $grid->column('id')->sortable();
            $grid->column('title');
            $grid->column('sort');
            $grid->column('pic')->image('',50,50);
            $grid->column('status')->switch();

            $grid->showQuickEditButton();
            $grid->enableDialogCreate();
            $grid->disableColumnSelector();
            $grid->disableEditButton();
            $grid->disableViewButton();
            $grid->disableFilterButton();

        });
    }


    /**
     * Make a form builder.
     *
     * @return Form
     */
    protected function form()
    {
        return Form::make(new GoodsCategory(), function (Form $form) {
            $form->text('title');
            $form->hidden('pid')->default(0);
            $form->text('sort');
            $form->image('pic')->uniqueName();
            $form->switch('status');
            $form->hidden('country')->default(config('app.goods_country'));
            //$form->text('is_home');
            //$form->text('limit_purchase');
        });
    }
}
